var baseAll={
     timeout:30000,//设置网络的延时时间  30s
     GetRequest:function () {
          var url = location.search; //获取url中"?"符后的字串
          var theRequest = new Object();
          if (url.indexOf("?") != -1) {
               var str = url.substr(1);
               var strs = str.split("&");
               for(var i = 0; i < strs.length; i ++) {
                    theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
               }
          }
          return theRequest;
     },
     //日期格式化转换-------------------
     dateToString:function(nows){
          var now=new Date(nows);
          var year = now.getFullYear();
          var month =now.getMonth() + 1;
          var day = now.getDate();
          var hour = now.getHours();
          var minute = now.getMinutes();
          var second = now.getSeconds();
          month=month<10?"0"+month:month;
          day=day<10?"0"+day:day;
          hour=hour<10?"0"+hour:hour;
          minute=minute<10?"0"+minute:minute;
          second=second<10?"0"+second:second;
          var dateTime = year + "-" + month + "-" + day +" "+ hour +":"+minute+":"+second;
          return dateTime;
     },
     //通过用户的账号获取IP地址--------------------
     getIpByAccount:function(account,fn){
          $.ajax({
               type:"get",
               url:oPublic.basePath()+"/s/bike/owner/mapper",
               data:{
                    account:account
               },
               success:function(data){
                    if(data.opStatus==0){
                         var contextPath=data.data.contextPath;
                         fn&&fn(contextPath);
                    }else{
                         oPublic.pubilcModal(data.msgDesc,"确定");
                    }
               },
               error:function(){
                   oPublic.pubilcModal("数据请求延迟","确定");
               }
          })
     },
     //获取跳转到url地址-----------
     getUrl:function (url,page) {
          var index=url.lastIndexOf("/");
          var preStr=url.substr(0,index);
          return preStr+"/"+page;
     },
     pubilcModal:function(title,btns,handle){
          btns=btns||"确定";
          var oHtml= '<section class="model" id="publicModal">'+
               '<div class="Info_mode pCenter txt_center">'+
               '<h4>'+title+'</h4>'+
               '<p>'+btns+'</p>'+
               '</div>'+
               '</section>';
          $("body").append(oHtml);
          $("#publicModal").on("click","p",function(){
               $(this).parents(".model").remove();
               handle&&handle();
          });
     },

    //加载动画
    loadingAnimation:function(){
        <!-- 界面加载 -->
        var content='<section class="loading_model">'+
                         '<img src="../images/loading.gif" alt="" class="pCenter">'+
                    '</section>';
        return content;
    },
    //添加加载动画
    addLoading:function(){
        $("body").append(baseAll.loadingAnimation());
    },
    //移除加载动画
    closeLoading:function(){
        $("body").find(".loading_model").remove();
    },
    /*
    *     判断手机设备
    *     ios       苹果手机
    *     android   安卓手机
    */
    isMobileDevice:function(){
        var u = navigator.userAgent;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        var deviceName=null;//初始化设备
        if(isAndroid){
             deviceName='android';
             return deviceName;
        }else if(isiOS){
             deviceName='ios';
             return deviceName;
        }else{
             return -1;
        }
    },
    /*
    *  IOS初始化操作初始化，必须执行这个
    * */
    setupWebViewJavascriptBridge:function (callback) {
        if (window.WebViewJavascriptBridge) {
            return callback(WebViewJavascriptBridge);
        }
        if (window.WVJBCallbacks) {
            return window.WVJBCallbacks.push(callback);

        }
        window.WVJBCallbacks = [callback];
        var WVJBIframe = document.createElement('iframe');
        WVJBIframe.style.display = 'none';
        WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
        document.documentElement.appendChild(WVJBIframe);
        setTimeout(function(){document.documentElement.removeChild(WVJBIframe)}, 0)
    },
    /*
    *   IOS webView运行接口
    * */
    runWebViewJavascriptBridge:function(name,params,handle){
        // 这是提供给OC调用的接口 demo
        baseAll.setupWebViewJavascriptBridge( function(bridge) {
            bridge.registerHandler('loadEnd', function(data,responseCallback){
                WebViewJavascriptBridge.callHandler(name, params, function (response) {
                    handle && handle(response);//回调函数  进行处理数据
                });
            })
        })
    },
    runWebViewJavascriptBridgeArr:function(handle){
        // 这是提供给OC调用的接口 demo
        baseAll.setupWebViewJavascriptBridge( function(bridge) {
            bridge.registerHandler('loadEnd',function(data,responseCallback){
                handle&&handle(data,responseCallback);
            });
        })
    },
    /*
    *   页面按钮返回
    * */
    deviceReturn:function(){
        if(baseAll.isMobileDevice()=='ios'){
            $('.back_btn').eq(0).parents(".top_fixed").hide().next().hide();
        }
        document.getElementsByClassName('back_btn')[0].onclick=function(){
            baseAll.returnHandle();
        }
    },
    /*返回判断 设备*/
    returnHandle:function(){
        if(baseAll.isMobileDevice()=='android'){
            AnroidWebActivity.goBack();
        }else{
            WebViewJavascriptBridge.callHandler('goBack',null,null);
        }
    },
    /*关闭页面 设备*/
    closePageDevice:function(){
        if(baseAll.isMobileDevice()=='android'){
            AnroidWebActivity.finish();//页面关闭
        }else{
            WebViewJavascriptBridge.callHandler('logout',null,null);
        }
    }

};




